﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Read.Api.Application.Command.SlaughtsWay;

namespace Traceability_Management.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SlaughtsAllController : ControllerBase
    {
        IMediator mediator;

        public SlaughtsAllController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]

        public async Task<ApiResult<int>> AddSlaughts(Slaughts Slaughts)
        {
            try
            {
                AddSlaughtsCommand AddSlaughtsCommand = new AddSlaughtsCommand() 
                {
                    Slaughts = Slaughts
                };
                return await mediator.Send(AddSlaughtsCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdateSlaughts(Slaughts Slaughts)
        {
            try
            {
                UpdateSlaughtsCommand UpdateSlaughtsCommand = new UpdateSlaughtsCommand()
                {
                    Slaughts = Slaughts
                };
                return await mediator.Send(UpdateSlaughtsCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<Slaughts>> FistSlaughts([FromQuery]FirstSlaughtsWayCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> CheckSlaughtsImages( [FromQuery]CheckSlaughtsImagesCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> CheckSlauCompanyImages([FromQuery] CheckSlauCompanyImagesCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
